OOP Python Code — Defining Classes

# Let's write our own Employee class!
class Employee:
    def __init__(self, fname, lname):
        self.firstname = fname
        self.lastname = lname
        # self._salaray = 500

    def printname(self):
        print(self.firstname, self.lastname)


newHire = Employee("Layne", "Ramirez")
# print(newHire.firstname)
print(type(newHire))
newHire.printname()

# Knowledge Check #2: instantiate another object

Leave a Reply